package com.hualude.roadsign.service.impl;

import com.hualude.roadsign.dto.AlarmPushDto;
import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.MonthCountDto;
import com.hualude.roadsign.repository.AlarmPushRepository;
import com.hualude.roadsign.service.HighLeverAlarmService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HighLeverAlarmServiceImpl implements HighLeverAlarmService {

    @Resource
    private AlarmPushRepository alarmPushRepository;

    @Override
    public DTResponseDto showAlarmHistory(DTRequestDto dtRequestDto, String deviceId, Integer deviceType, String orgIds, String time) throws Exception {
        List<AlarmPushDto> dtos = alarmPushRepository.getAlarmHistory4DT(dtRequestDto, deviceId, deviceType, orgIds, time);
        int count = alarmPushRepository.getAlarmHistoryCount4DT(dtRequestDto, deviceId, deviceType, orgIds, time);
        return new DTResponseDto(dtRequestDto.getDraw(), count, count, dtos);
    }

    @Override
    public List<MonthCountDto> getMonthCount(String alarmPushType, String startTime, String endTime, String orgIds, String deviceId) throws Exception {
        return alarmPushRepository.getMonthCount(alarmPushType, startTime, endTime, orgIds, deviceId);
    }

}
